import path from 'path'
import { defineConfig, loadEnv } from 'vite'

import createVitePlugins from './vite.plugins'


export default defineConfig(({ mode, command }) => {
  const env = loadEnv(mode, process.cwd())
  return {
    plugins: createVitePlugins(env, command === 'build'),
    base: './',

    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src'),
        "~": path.resolve(__dirname, "./"),
      }
    },
    server: {
      port: 8080,
      host: true,
      open: true,
      proxy: {
        '/api': {
          target: 'http://127.0.0.1',
          changeOrigin: true
        }
      }
    }
  }
})
